package edu.sctu.java.lab03;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018/5/28.
 */
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        resp.setHeader("content-type","text/html;charset=UTF-8");
//        PrintWriter out=resp.getWriter();
//        out.write("<table>\n" +
//                "            <tr>\n" +
//                "                <td>编号</td>\n" +
//                "                <td>用户名</td>\n" +
//                "                <td>密码</td>\n" +
//                "                <td>操作1</td>\n" +
//                "                <td>操作2</td>\n" +
//                "            </tr>\n" +
//                "            <tr>\n" +
//                "                <td>123</td>\n" +
//                "                <td>456</td>\n" +
//                "                <td>789</td>\n" +
//                "                <td>删除</td>\n" +
//                "                <td>更新</td>\n" +
//                "            </tr>\n" +
//                "        </table>");

        //
        Database database= new Database();
        List<User> userList=database.getUserList();

        req.setAttribute("userList",userList);

        req.getRequestDispatcher("/userList.jsp").forward(req,resp);
    }
}
